package com.java.demo.controller;

import com.java.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class UserController1 {
    //Setter注入
    //优点:复合单一设计原则
    //缺点：1不能注入final修饰变量
    //     2.使用setter注入的对象可能会被修改。
    private UserService userService;

    @Autowired
    public void setUserService(UserService userService){
        this.userService = userService;
    }
    public void hello (){
        System.out.println("UserController1");
        userService.hello();
    }
}
